package com.example.allshengmedical.experimentanalyze.activity;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import android.R.integer;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.FragmentTransaction;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.allshengmedical.R;
import com.example.allshengmedical.base.BaseActivity;
import com.example.allshengmedical.base.BaseApplication;
import com.example.allshengmedical.experimentanalyze.activity.CtFragment.CallBackValue;
import com.example.allshengmedical.experimentanalyze.bean.AdvancedSettingBean;
import com.example.allshengmedical.experimentanalyze.bean.CtSettingBean;
import com.example.allshengmedical.experimentanalyze.presenter.ParameterSettingActivityPresenter;
import com.example.allshengmedical.experimentanalyze.presenter.ReportActivityPresenter;
import com.example.allshengmedical.experimentanalyze.view.IParameterView;
import com.example.allshengmedical.experimentanalyze.view.IReportView;
import com.example.allshengmedical.experimentnew.activity.MethodsActivity1;
import com.example.allshengmedical.experimentnew.bean.MethodBean;
import com.example.allshengmedical.experimentrun.activity.TemparetureActivity;
import com.example.allshengmedical.mainmenu.activity.MainMenuActivity;
import com.example.allshengmedical.util.ByAlert;
import com.example.allshengmedical.util.FileManagerUtil;
import com.example.allshengmedical.util.LogUtil;
import com.example.allshengmedical.util.SharedPreferencesUtils;


//参数设置界面
public class ParameterSettingActivity extends BaseActivity
		implements
		IParameterView,
		CallBackValue,
		com.example.allshengmedical.experimentanalyze.activity.AdvancedFragment.CallBackValue {
	public final int TASK_LOOP_COMPLETE = 0;
	ProgressDialog pd;
	private PopupWindow menuPopupWindow;
	private boolean menuboo;
	private TextView ct_tv;
	private TextView flag_tv;
	private TextView adveced_tv;
	private TextView melt_tv;
	private TextView Relative_tv;
	private LinearLayout fragment_lin;
	private CtFragment ctFragment;
	private FlagFragment flagFragment;
	private AdvancedFragment advancedFragment;
	private MeltCurveAdvancedFragment meltCurveAdvancedFragment;
	private RelativeFragment relativeFragment;
	private ParameterSettingActivityPresenter parameterSettingActivityPresenter;

	public ArrayList<CtSettingBean> ctSettingBeans = new ArrayList<CtSettingBean>();
	public Boolean defaultBaselineBoo;
	public String defaultStart, defaultEnd;
	public ArrayList<AdvancedSettingBean> advancedSettingBeans = new ArrayList<AdvancedSettingBean>();
	public Boolean defaultThresholdBoo;
	public String defaultThreshold;
	private String appFilePath = Environment.getExternalStorageDirectory()
			+ "/" + "AllShengMedical";

	// 数据
	String folderName;
	String fileName;

	StringBuffer contextString = new StringBuffer();
	
	RelativeLayout white_line;
	
	private ArrayList<MethodBean> activityMethodBeans = new ArrayList<MethodBean>();

	@Override
	protected int setcontent() {
		return R.layout.activity_parameter_setting;
	}

	@Override
	protected void initView() {
		parameterSettingActivityPresenter = new ParameterSettingActivityPresenter(
				this);
		getinfo();
		parameterSettingActivityPresenter.initAppHead();
		parameterSettingActivityPresenter.initBottomView();
		
		if (AnalyzeAmplificationplotActivity.getInstence().repititions == 0) {
			// 不能使用此页面
			white_line.setVisibility(View.VISIBLE);
			return;
		} else if (AnalyzeAmplificationplotActivity.getInstence().repititions == 1) {
			
			// 不能使用此页面
			white_line.setVisibility(View.VISIBLE);
			return;
		}else {
			white_line.setVisibility(View.GONE);
		}

		
		parameterSettingActivityPresenter.changeFragment();
		getDefaultData();
	}

	private void getinfo() {

		//
		folderName = SharedPreferencesUtils.get(ParameterSettingActivity.this,
				BaseApplication.FILEMANGER_PREPAREFOLDERPATH, "") + "";
		fileName = SharedPreferencesUtils.get(ParameterSettingActivity.this,
				BaseApplication.FILEMANGER_PREPAREFILENAME, "") + "";

		String path = appFilePath + "/" + folderName;

		File file = new File(path + "/" + fileName);

		FileInputStream in = null;
		BufferedReader reader = null;
		contextString = new StringBuffer();
		try {
			in = new FileInputStream(file);
			reader = new BufferedReader(new InputStreamReader(in));
			String line = "";
			while ((line = reader.readLine()) != null) {
				contextString.append(line);
				contextString.append(",");
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			if (reader != null) {
				try {
					reader.close();
				} catch (Exception e2) {
					e2.printStackTrace();
				}
			}
		}

		// BufferedReader reader = null;
		// contextString=new StringBuffer();
		// try {
		// System.out.println("以行为单位读取文件内容，一次读一整行:");
		// reader = new BufferedReader(new FileReader(file));
		// String tempString = null;
		// int line = 1;
		// // 一次读入一行，直到读入null为文件结束
		// while ((tempString = reader.readLine()) != null) {
		// // 显示行号
		// // System.out.println("line " + line + ": " + tempString);
		// // Log.e("--", tempString);
		// contextString.append(tempString);
		// contextString.append(",");
		// line++;
		// }
		// reader.close();
		// } catch (IOException e) {
		// e.printStackTrace();
		// } finally {
		// if (reader != null) {
		// try {
		// reader.close();
		// // LogUtil.e("!!", contextString + "");
		//
		// } catch (IOException e1) {
		// }
		// }
		// }

		

		

		int index = 0;
		// 上面解析
		while (!(contextString.indexOf("steptType:", index) <= 0)) {

			// steptType:
			String steptType;
			steptType = contextString.substring(contextString.indexOf("steptType:", index) + 10,

					contextString.indexOf(",temperature:", index));

			// LogUtil.e(steptType);

			// temperature
			String temperature;
			temperature = contextString.substring(contextString.indexOf(",temperature:", index) + 13,

					contextString.indexOf(",time:", index));

			// LogUtil.e(temperature);
			// time
			String time;
			time = contextString.substring(contextString.indexOf(",time:", index) + 6,

					contextString.indexOf(",goTo:", index));
					// LogUtil.e(time);

			// goTo
			String goTo;
			goTo = contextString.substring(contextString.indexOf(",goTo:", index) + 6,

					contextString.indexOf(",Repititions:", index));
			// LogUtil.e(goTo);
			// Repititions
			String repititions;
			repititions = contextString.substring(contextString.indexOf(",Repititions:", index) + 13,

					contextString.indexOf(",deltaT:", index));
			// LogUtil.e(repititions);
			// deltaT
			String deltaT;
			deltaT = contextString.substring(contextString.indexOf(",deltaT:", index) + 8,

					contextString.indexOf(",rightSelect:", index));
			// LogUtil.e(deltaT);

			int nextIndex = contextString.indexOf("steptType:", index) + 10;

			// rightSelect
			String rightSelect;

			if (contextString.indexOf(",steptType:", nextIndex) < 0) {
				rightSelect = contextString.substring(contextString.indexOf(",rightSelect:", index) + 13,
						contextString.indexOf(",,pointMap", index));
				if ("null".equals(rightSelect)) {
					rightSelect = "";
				}

			} else {
				rightSelect = contextString.substring(contextString.indexOf(",rightSelect:", index) + 13,

						contextString.indexOf(",steptType:", nextIndex));
				if ("null".equals(rightSelect)) {
					rightSelect = "";
				}
			}
			// LogUtil.e(rightSelect);
			index = contextString.indexOf(",rightSelect:", index) + 13;

			activityMethodBeans.add(new MethodBean(steptType.trim(), temperature.trim(), time.trim(), goTo.trim(),
					repititions.trim(), deltaT.trim()));
		}
		// 获取重复次数

		int stepNum = Integer.parseInt(contextString
				.substring(contextString.indexOf(",readDataString: ") + 17, contextString.indexOf(",,Methods")).trim());
//		getRepititions(stepNum);
		// repititions = Integer.parseInt(activityMethodBeans.get(stepNum -
		// 1).getRepititions());
	}

	private void getDefaultData() {
		contextString = new StringBuffer();
		folderName = SharedPreferencesUtils.get(this,
				BaseApplication.FILEMANGER_PREPAREFOLDERPATH, "") + "";
		fileName = SharedPreferencesUtils.get(this,
				BaseApplication.FILEMANGER_PREPAREFILENAME, "") + "";

		String path = appFilePath + "/" + folderName;

		File file = new File(path + "/" + fileName);
		
		FileInputStream in =null;
		BufferedReader reader=null;
		contextString=new StringBuffer();
		try {
			in =new FileInputStream(file);
			reader=new BufferedReader(new InputStreamReader(in));
			String line ="";
			while((line =reader.readLine())!=null){
				contextString.append(line);
				contextString.append(",");
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			if(reader != null){
				try {
					reader.close();
				} catch (Exception e2) {
					e2.printStackTrace();
				}
			}
		}
		
//		BufferedReader reader = null;
//		contextString =new StringBuffer();
//		System.gc();
//		try {
//			System.out.println("以行为单位读取文件内容，一次读一整行:");
//			reader = new BufferedReader(new FileReader(file));
//			String tempString = null;
//			int line = 1;
//			// 一次读入一行，直到读入null为文件结束
//			while ((tempString = reader.readLine()) != null) {
//				// 显示行号
//				// System.out.println("line " + line + ": " + tempString);
//				// Log.e("--", tempString);
//				contextString.append(tempString);
//				contextString.append(",");
//				line++;
//			}
//			reader.close();
//		} catch (IOException e) {
//			e.printStackTrace();
//		} finally {
//			if (reader != null) {
//				try {
//					reader.close();
//					// LogUtil.e("!!", contextString + "");
//
//				} catch (IOException e1) {
//				}
//			}
//		}

	}

	@Override
	protected void initData() {
		// TODO Auto-generated method stub

	}

	@Override
	public void initAppHead() {
		setActionBar();
		setSystemTime();
	}

	@Override
	public void initBottomView() {
//		setBottomView();
	}

	@Override
	public void changeFragment() {
		// TODO Auto-generated method stub
		initCTFragment();
		ct_tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				initCTFragment();
			}
		});
		flag_tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub

				initFlagFragment();
			}
		});
		adveced_tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub

				initAdvecedFragment();
			}
		});
		melt_tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				initMeltCurveFragment();
			}

		});
		Relative_tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				initRelativeFragment();
			}

		});

	}

	protected void initRelativeFragment() {
		// TODO Auto-generated method stub
		Relative_tv.setBackgroundColor(getResources().getColor(R.color.blue));
		melt_tv.setBackgroundColor(getResources().getColor(R.color.white));
		ct_tv.setBackgroundColor(getResources().getColor(R.color.white));
		adveced_tv.setBackgroundColor(getResources().getColor(R.color.white));
		flag_tv.setBackgroundColor(getResources().getColor(R.color.white));
		Relative_tv.setTextColor(getResources().getColor(R.color.white));
		melt_tv.setTextColor(getResources().getColor(R.color.black));
		flag_tv.setTextColor(getResources().getColor(R.color.black));
		ct_tv.setTextColor(getResources().getColor(R.color.black));
		adveced_tv.setTextColor(getResources().getColor(R.color.black));
		FragmentTransaction transaction = getSupportFragmentManager()
				.beginTransaction();
		if (relativeFragment == null) {
			relativeFragment = new RelativeFragment();
			// transaction.add(R.id.fragment_lin, relativeFragment);
		}
		transaction.replace(R.id.fragment_lin, relativeFragment);
		// hideAllFragment(transaction);
		// transaction.show(relativeFragment);
		transaction.commit();
	}

	private void initMeltCurveFragment() {
		// TODO Auto-generated method stub
		melt_tv.setBackgroundColor(getResources().getColor(R.color.blue));
		ct_tv.setBackgroundColor(getResources().getColor(R.color.white));
		adveced_tv.setBackgroundColor(getResources().getColor(R.color.white));
		flag_tv.setBackgroundColor(getResources().getColor(R.color.white));
		Relative_tv.setBackgroundColor(getResources().getColor(R.color.white));
		melt_tv.setTextColor(getResources().getColor(R.color.white));
		flag_tv.setTextColor(getResources().getColor(R.color.black));
		ct_tv.setTextColor(getResources().getColor(R.color.black));
		adveced_tv.setTextColor(getResources().getColor(R.color.black));
		Relative_tv.setTextColor(getResources().getColor(R.color.black));
		FragmentTransaction transaction = getSupportFragmentManager()
				.beginTransaction();
		if (meltCurveAdvancedFragment == null) {
			meltCurveAdvancedFragment = new MeltCurveAdvancedFragment();
			// transaction.add(R.id.fragment_lin, meltCurveAdvancedFragment);
		}
		transaction.replace(R.id.fragment_lin, meltCurveAdvancedFragment);
		// hideAllFragment(transaction);
		// transaction.show(meltCurveAdvancedFragment);
		transaction.commit();
	}

	private void initCTFragment() {
		ct_tv.setBackgroundColor(getResources().getColor(R.color.blue));
		adveced_tv.setBackgroundColor(getResources().getColor(R.color.white));
		flag_tv.setBackgroundColor(getResources().getColor(R.color.white));
		melt_tv.setBackgroundColor(getResources().getColor(R.color.white));
		Relative_tv.setBackgroundColor(getResources().getColor(R.color.white));
		ct_tv.setTextColor(getResources().getColor(R.color.white));
		flag_tv.setTextColor(getResources().getColor(R.color.black));
		adveced_tv.setTextColor(getResources().getColor(R.color.black));
		melt_tv.setTextColor(getResources().getColor(R.color.black));
		Relative_tv.setTextColor(getResources().getColor(R.color.black));
		FragmentTransaction transaction = getSupportFragmentManager()
				.beginTransaction();
		if (ctFragment == null) {
			ctFragment = new CtFragment();
			// transaction.add(R.id.fragment_lin, ctFragment);
		}
		transaction.replace(R.id.fragment_lin, ctFragment);
		// hideAllFragment(transaction);
		// transaction.show(ctFragment);
		transaction.commit();
	}

	private void initFlagFragment() {
		flag_tv.setBackgroundColor(getResources().getColor(R.color.blue));
		ct_tv.setBackgroundColor(getResources().getColor(R.color.white));
		adveced_tv.setBackgroundColor(getResources().getColor(R.color.white));
		melt_tv.setBackgroundColor(getResources().getColor(R.color.white));
		Relative_tv.setBackgroundColor(getResources().getColor(R.color.white));
		ct_tv.setTextColor(getResources().getColor(R.color.black));
		adveced_tv.setTextColor(getResources().getColor(R.color.black));
		melt_tv.setTextColor(getResources().getColor(R.color.black));
		Relative_tv.setTextColor(getResources().getColor(R.color.black));
		flag_tv.setTextColor(getResources().getColor(R.color.white));
		FragmentTransaction transaction = getSupportFragmentManager()
				.beginTransaction();
		if (flagFragment == null) {
			flagFragment = new FlagFragment();
			// transaction.add(R.id.fragment_lin, flagFragment);
		}
		// hideAllFragment(transaction);
		// transaction.show(flagFragment);

		transaction.replace(R.id.fragment_lin, flagFragment);
		transaction.commit();
	}

	private void initAdvecedFragment() {
		adveced_tv.setBackgroundColor(getResources().getColor(R.color.blue));
		flag_tv.setBackgroundColor(getResources().getColor(R.color.white));
		ct_tv.setBackgroundColor(getResources().getColor(R.color.white));
		melt_tv.setBackgroundColor(getResources().getColor(R.color.white));
		Relative_tv.setBackgroundColor(getResources().getColor(R.color.white));
		flag_tv.setTextColor(getResources().getColor(R.color.black));
		ct_tv.setTextColor(getResources().getColor(R.color.black));
		melt_tv.setTextColor(getResources().getColor(R.color.black));
		Relative_tv.setTextColor(getResources().getColor(R.color.black));
		adveced_tv.setTextColor(getResources().getColor(R.color.white));
		FragmentTransaction transaction = getSupportFragmentManager()
				.beginTransaction();
		if (advancedFragment == null) {
			advancedFragment = new AdvancedFragment();
			// // transaction.add(R.id.fragment_lin, advancedFragment);
		}
		// hideAllFragment(transaction);
		// transaction.show(advancedFragment);

		transaction.replace(R.id.fragment_lin, advancedFragment);
		transaction.commit();
	}

	private void hideAllFragment(FragmentTransaction transaction) {
		if (advancedFragment != null) {
			transaction.hide(advancedFragment);
		}
		if (flagFragment != null) {
			transaction.hide(flagFragment);
		}
		if (ctFragment != null) {
			transaction.hide(ctFragment);
		}
		if (meltCurveAdvancedFragment != null) {
			transaction.hide(meltCurveAdvancedFragment);
		}
		if (relativeFragment != null) {
			transaction.hide(relativeFragment);
		}
	}

	public void setActionBar() {


		
		//
		folderName = SharedPreferencesUtils.get(
				ParameterSettingActivity.this,
				BaseApplication.FILEMANGER_PREPAREFOLDERPATH, "")
				+ "";
		fileName = SharedPreferencesUtils.get(
				ParameterSettingActivity.this,
				BaseApplication.FILEMANGER_PREPAREFILENAME, "")
				+ "";

		String path = appFilePath + "/" + folderName;

		File file = new File(path + "/" + fileName);
		BufferedReader reader = null;
		contextString=new StringBuffer();
		try {
			System.out.println("以行为单位读取文件内容，一次读一整行:");
			reader = new BufferedReader(new FileReader(file));
			String tempString = null;
			int line = 1;
			// 一次读入一行，直到读入null为文件结束
			while ((tempString = reader.readLine()) != null) {
				// 显示行号
				// System.out.println("line " + line + ": " + tempString);
				// Log.e("--", tempString);
				contextString.append(tempString);
				contextString.append(",");
				line++;
			}
			reader.close();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (reader != null) {
				try {
					reader.close();
					// LogUtil.e("!!", contextString + "");

				} catch (IOException e1) {
				}
			}
		}

		
		Button leftfirstBtn, leftsecondBtn, leftThirdBtn, leftForthBtn, leftFifthBtn, leftSixthBtn, leftSevenThBtn, leftEighthBtn, leftNinethBtn,leftTenth_btn;
		// TextView title;

		String ExperimentType =contextString.subSequence(contextString.indexOf("ExperimentType:")+15, contextString.indexOf(",SampleType:"))+"";
		leftfirstBtn = BindView(R.id.leftfirst_btn);
		leftfirstBtn.setVisibility(View.VISIBLE);
		leftsecondBtn = BindView(R.id.leftsecond_btn);
		leftsecondBtn.setVisibility(View.VISIBLE);
		leftThirdBtn = BindView(R.id.leftThird_btn);
		leftThirdBtn.setVisibility(View.VISIBLE);
		leftForthBtn = BindView(R.id.leftForth_btn);
		leftForthBtn.setVisibility(View.VISIBLE);
		leftFifthBtn = BindView(R.id.leftFifth_btn);
		leftFifthBtn.setVisibility(View.VISIBLE);
		leftSixthBtn = BindView(R.id.leftSixth_btn);
		leftSixthBtn.setVisibility(View.VISIBLE);
		leftSevenThBtn = BindView(R.id.leftSevenTh_btn);
		leftSevenThBtn.setVisibility(View.VISIBLE);
		leftEighthBtn = BindView(R.id.leftEighth_btn);
		leftEighthBtn.setVisibility(View.VISIBLE);
		leftNinethBtn = BindView(R.id.leftNineth_btn);
		leftNinethBtn.setVisibility(View.VISIBLE);
		
		
		if(ExperimentType.equals("绝对定量") || ExperimentType.equals("Absolute Quantitation")){
			leftTenth_btn = BindView(R.id.leftTenth_btn);
			leftTenth_btn.setVisibility(View.INVISIBLE);
			
			leftfirstBtn.setText(R.string.item_actionbar_home);
			leftsecondBtn.setText(R.string.ana_amplification);
			leftThirdBtn.setText(R.string.ana_standarad);
			leftForthBtn.setText(R.string.ana_multiplot);
			leftFifthBtn.setText(R.string.ana_rawdata);
			leftSixthBtn.setText(R.string.ana_meltcurve);
			leftSevenThBtn.setText(R.string.ana_result);
			leftEighthBtn.setText(R.string.ana_report);
			leftNinethBtn.setText(R.string.ana_analysissetting);
			
			leftNinethBtn.setSelected(true);
		
			
			leftThirdBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this,
							"", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(
										ParameterSettingActivity.this,
										AnalyzeStandardCurveActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener
										.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();
				}
			});
			leftForthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(
										ParameterSettingActivity.this,
										AnalyzeMulticomponentPlotActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener
										.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftFifthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this,
							"", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(
										ParameterSettingActivity.this,
										AnalyzeRawDataActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener
										.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftSixthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this,
							"", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(
										ParameterSettingActivity.this,
										AnalyzeMeltCurveActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener
										.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftSevenThBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this,
							"", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(
										ParameterSettingActivity.this,
										AnalyzeRawDataTwoActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener
										.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftEighthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this,
							"", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(
										ParameterSettingActivity.this,
										ReportActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener
										.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftNinethBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this,
							"", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(
										ParameterSettingActivity.this,
										ParameterSettingActivity.class);
								startActivity(intent);
							} finally {
								messageListener
										.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			
		}else if (ExperimentType.equals("标准曲线相对定量") || ExperimentType.equals("Standard Curve Relative Quantitation")) {
			
			leftTenth_btn = BindView(R.id.leftTenth_btn);
			leftTenth_btn.setVisibility(View.VISIBLE);
			leftfirstBtn.setText(R.string.item_actionbar_home);
			leftsecondBtn.setText(R.string.ana_amplification);
			leftThirdBtn.setText(R.string.ana_standarad);
			leftForthBtn.setText(R.string.ana_multiplot);
			leftFifthBtn.setText(R.string.ana_rawdata);
			leftSixthBtn.setText(R.string.ana_meltcurve);
			leftSevenThBtn.setText(R.string.ana_rela_quan);
			leftEighthBtn.setText(R.string.ana_result);
			leftNinethBtn.setText(R.string.ana_report);
			leftTenth_btn.setText(R.string.ana_analysissetting);
			
			leftTenth_btn.setSelected(true);
			
			leftThirdBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this,
							"", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(
										ParameterSettingActivity.this,
										AnalyzeStandardCurveActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener
										.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();
				}
			});
			leftForthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(
										ParameterSettingActivity.this,
										AnalyzeMulticomponentPlotActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener
										.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftFifthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this,
							"", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(
										ParameterSettingActivity.this,
										AnalyzeRawDataActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener
										.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftSixthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this,
							"", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(
										ParameterSettingActivity.this,
										AnalyzeMeltCurveActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener
										.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftSevenThBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this,
							"", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(
										ParameterSettingActivity.this,
										AnalyzeRelativeQuanticationActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener
										.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftEighthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this,
							"", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(
										ParameterSettingActivity.this,
										AnalyzeRawDataTwoActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener
										.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftNinethBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this,
							"", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(
										ParameterSettingActivity.this,
										ReportActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener
										.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftTenth_btn.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View v) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this,
							"", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(
										ParameterSettingActivity.this,
										ParameterSettingActivity.class);
								startActivity(intent);
							} finally {
								messageListener
										.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

					
				}
			});
		} else if (ExperimentType.equals("比较ct值相对定量") || ExperimentType.equals("⊿Ct Relative Quantitation")) {

			leftTenth_btn = BindView(R.id.leftTenth_btn);
			leftTenth_btn.setVisibility(View.VISIBLE);

			leftfirstBtn.setText(R.string.item_actionbar_home);
			leftsecondBtn.setText(R.string.ana_amplification);
			leftThirdBtn.setText(R.string.ana_multiplot);
			leftForthBtn.setText(R.string.ana_rawdata);
			leftFifthBtn.setText(R.string.ana_meltcurve);
			leftSixthBtn.setText(R.string.ana_rela_quan);
			leftSevenThBtn.setText(R.string.ana_result);
			leftEighthBtn.setText(R.string.ana_report);
			leftNinethBtn.setText(R.string.ana_analysissetting);
			leftTenth_btn.setVisibility(View.INVISIBLE);
			leftNinethBtn.setSelected(true);

			leftThirdBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(ParameterSettingActivity.this,
										AnalyzeMulticomponentPlotActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();
				}
			});
			leftForthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(ParameterSettingActivity.this, AnalyzeRawDataActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftFifthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(ParameterSettingActivity.this,
										AnalyzeMeltCurveActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftSixthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(ParameterSettingActivity.this,
										AnalyzeRelativeQuanticationActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftSevenThBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(ParameterSettingActivity.this,
										AnalyzeRawDataTwoActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftEighthBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(ParameterSettingActivity.this, ReportActivity.class);
								startActivity(intent);
								finish();
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});
			leftNinethBtn.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					System.gc();
					pd = ProgressDialog.show(ParameterSettingActivity.this, "", "loading...", true, true);

					new Thread() {
						public void run() {
							try {
								Intent intent = new Intent(ParameterSettingActivity.this,
										ParameterSettingActivity.class);
								startActivity(intent);
							} finally {
								messageListener.sendEmptyMessage(TASK_LOOP_COMPLETE);
							}
						}
					}.start();

				}
			});

		}
		
		

		

		leftfirstBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				System.gc();
				// pd = ProgressDialog.show(this, "", "loading...", true, true);
				pd = ProgressDialog.show(ParameterSettingActivity.this,
						"", "loading...", true, true);

				new Thread() {
					public void run() {
						try {
							BaseApplication.getInstance().finishAll();
							Intent intent = new Intent(
									ParameterSettingActivity.this,
									MainMenuActivity.class);
							startActivity(intent);
						} finally {
							messageListener
									.sendEmptyMessage(TASK_LOOP_COMPLETE);
						}
					}
				}.start();
				finish();

			}
		});
		leftsecondBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				System.gc();
				pd = ProgressDialog.show(ParameterSettingActivity.this,
						"", "loading...", true, true);

				new Thread() {
					public void run() {
						try {
							Intent intent = new Intent(
									ParameterSettingActivity.this,
									AnalyzeAmplificationplotActivity.class);
							startActivity(intent);
							finish();
						} finally {
							messageListener
									.sendEmptyMessage(TASK_LOOP_COMPLETE);
						}
					}
				}.start();
			}
		});
		
		Boolean noRongJie=false;
		for(int i= 0; i<activityMethodBeans.size();i++){
			if(!TextUtils.isEmpty(activityMethodBeans.get(i).getDeltaT())){
				noRongJie=true;
			}
		}
		if(noRongJie){
			 if (getText(R.string.ana_meltcurve).equals(leftFifthBtn.getText())) {
				 leftFifthBtn.setVisibility(View.GONE);
			}else if (getText(R.string.ana_meltcurve).equals(leftSixthBtn.getText())) {
				leftSixthBtn.setVisibility(View.GONE);
			}
		}
	

	
	
	}

	// menu的弹出窗口
	private void showMenuPopupWindow(View v) {

		if (null == menuPopupWindow || !menuPopupWindow.isShowing()) {
			View contentView = LayoutInflater.from(this).inflate(
					R.layout.fragment_run_menu, null);
			menuPopupWindow = new PopupWindow(contentView,
					LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
			menuPopupWindow.setBackgroundDrawable(new BitmapDrawable());
			menuPopupWindow.setTouchable(true);
			menuPopupWindow.setOutsideTouchable(true);
			menuPopupWindow.showAsDropDown(v, -40, -3);

			TextView amplificationTv, temperatureTv, methodTv;
			amplificationTv = (TextView) contentView
					.findViewById(R.id.amplificationTv);
			temperatureTv = (TextView) contentView
					.findViewById(R.id.temperatureTv);
			methodTv = (TextView) contentView.findViewById(R.id.methodTv);

			amplificationTv.setBackground(getResources().getDrawable(
					R.color.darkBlue));
			amplificationTv.setTextColor(this.getResources().getColor(
					R.color.white));
			temperatureTv.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {

					menuPopupWindow.dismiss();
					Intent intent = new Intent(ParameterSettingActivity.this,
							TemparetureActivity.class);
					startActivity(intent);

				}
			});
			methodTv.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					// Intent intent =new Intent(BaseInformationActivity, uri)
					menuPopupWindow.dismiss();
					Intent intent = new Intent(ParameterSettingActivity.this,
							AnalyzeMulticomponentPlotActivity.class);
					startActivity(intent);
				}
			});

		} else {
			menuPopupWindow.dismiss();
			menuboo = !menuboo;
		}

	}

	public void setSystemTime() {
		TextView date, fileName;
		date = BindView(R.id.date);
		fileName = BindView(R.id.file_name);

		// 获取系统时间
		SimpleDateFormat sdfDate = new SimpleDateFormat("MM dd,yyyy");
		date.setText(sdfDate.format(new Date()));

		// 文件路径置空
		fileName.setText(SharedPreferencesUtils.get(this,
				BaseApplication.FILEMANGER_PREPAREFOLDERPATH, "")
				+ "/"
				+ SharedPreferencesUtils.get(this,
						BaseApplication.FILEMANGER_PREPAREFILENAME, ""));
	}

	public void setBottomView() {
		Button bottomLeftFistBtn, bottomCenterBtn, bottomRightBtn;

		bottomLeftFistBtn = BindView(R.id.bottomLeftFistBtn);
		bottomCenterBtn = BindView(R.id.bottomCenterBtn);
		bottomRightBtn = BindView(R.id.bottomRightBtn);

		bottomLeftFistBtn.setVisibility(View.VISIBLE);
		// bottomCenterBtn.setVisibility(View.VISIBLE);
		bottomRightBtn.setVisibility(View.VISIBLE);

		bottomLeftFistBtn.setText(R.string.bottomView_back);
		// TODO 这个button的文字不确定暂时用A代替
		bottomCenterBtn.setText("A"); // 不确定！！！！！！！
		bottomRightBtn.setText("保存");

		bottomLeftFistBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// ByAlert.alert("back");
				pd = ProgressDialog.show(ParameterSettingActivity.this, "",
						"loading...", true, true);

				new Thread() {
					public void run() {
						try {
							Intent intent = new Intent(
									ParameterSettingActivity.this,
									ReportActivity.class);
							// intent.putStringArrayListExtra("data_list1",
							// data_list1);s
							startActivity(intent);
						} finally {
							messageListener
									.sendEmptyMessage(TASK_LOOP_COMPLETE);
						}
					}
				}.start();
				finish();

			}
		});

		bottomCenterBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				ByAlert.alert("A");

			}
		});
		bottomRightBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// 写文件 将数据写进文件

				FileManagerUtil fileManagerUtil = new FileManagerUtil();
				// 创建文件
				String folderName = SharedPreferencesUtils.get(
						ParameterSettingActivity.this,
						BaseApplication.FILEMANGER_PREPAREFOLDERPATH, "0")
						+ "";
				String fileName = SharedPreferencesUtils.get(
						ParameterSettingActivity.this,
						BaseApplication.FILEMANGER_PREPAREFILENAME, "0")
						+ "";

				// 这个方法和之前的一样，先一行一行的全部取出来。然后当遇到本页面数据。我们不做添加然后在这时我们要加入接下来的文件的数据
				String path = appFilePath + "/" + folderName;
				File file = new File(path + "/" + fileName);
				BufferedReader reader = null;
				StringBuffer contextString = new StringBuffer();
				try {
					System.out.println("以行为单位读取文件内容，一次读一整行:");
					reader = new BufferedReader(new FileReader(file));

					String tempString = "";
					int line = 1;
					// 一次读入一行，直到读入null为文件结束
					Boolean layoutOneBoolean = false;
					while ((tempString = reader.readLine()) != null) {
						// 显示行号
						// System.out.println("line " + line + ": "
						// +
						// tempString);
						// Log.e("--", tempString);
						if (tempString.contains("ParameterSetting")) {
							break;
						}

						contextString.append(tempString);
						contextString.append("\r\n");
						line++;
					}

					reader.close();

				} catch (IOException e) {
					e.printStackTrace();
				} finally {
					if (reader != null) {
						try {
							reader.close();
							// LogUtil.e("!!", contextString + "");

						} catch (IOException e1) {
						}
					}
				}

				// StringBuffer content = new StringBuffer();

				contextString.append("ParameterSetting" + "\r\n");
				contextString.append("\r\n" + "default" + "\r\n");
				contextString.append("\r\n" + "defaultThresholdBoo" + ":"
						+ defaultThresholdBoo);
				contextString.append("\r\n" + "defaultThreshold" + ":"
						+ defaultThreshold);
				contextString.append("\r\n" + "defaultBaselineBoo" + ":"
						+ defaultBaselineBoo);
				contextString.append("\r\n" + "defaultStart" + ":"
						+ defaultStart);
				contextString.append("\r\n" + "defaultEnd" + ":" + defaultEnd);

				contextString.append("\r\n" + "\r\n" + "ctSettingBeans"
						+ "\r\n");
				for (int i = 0; i < ctSettingBeans.size(); i++) {
					contextString.append("\r\n" + "targetName" + ":"
							+ ctSettingBeans.get(i).getTargetName());
					contextString.append("\r\n" + "threshold" + ":"
							+ ctSettingBeans.get(i).getThreshold());
					contextString.append("\r\n" + "baselineStart" + ":"
							+ ctSettingBeans.get(i).getBaselineStart());
					contextString.append("\r\n" + "baselineEnd" + ":"
							+ ctSettingBeans.get(i).getBaselineEnd());
					contextString.append("\r\n" + "useDaultSetting" + ":"
							+ ctSettingBeans.get(i).isUseDaultSetting());
					contextString.append("\r\n" + "isAutoThreshold" + ":"
							+ ctSettingBeans.get(i).isAutoThreshold());
					contextString.append("\r\n" + "isAutoBaseLine" + ":"
							+ ctSettingBeans.get(i).isAutoBaseLine());

				}

				if (advancedSettingBeans != null
						&& advancedSettingBeans.size() > 0) {

				} else {

					for (int i = 0; i < 32; i++) {
						if (i < 16) {
							// list1
							int index = i + 1;

							if (index <= 8) {
								advancedSettingBeans
										.add(new AdvancedSettingBean("A"
												+ index, "", "", "", "", false,
												false));
							} else {
								index = index - 8;
								advancedSettingBeans
										.add(new AdvancedSettingBean("B"
												+ index, "", "", "", "", false,
												false));
							}

						} else {
							// list2
							int index = i + 1;
							if (index <= 24) {
								index = index - 16;
								advancedSettingBeans
										.add(new AdvancedSettingBean("C"
												+ index, "", "", "", "", false,
												false));
							} else {
								index = index - 24;
								advancedSettingBeans
										.add(new AdvancedSettingBean("D"
												+ index, "", "", "", "", false,
												false));
							}

						}
					}

					// 获取

					if (contextString.toString().contains(
							"advancedSettingBeans")) {

						String advanceContextString = contextString.substring(
								contextString
										.indexOf(",,advancedSettingBeans,") + 23,
								contextString.length());

						// advancedSettingBeans
						int index = 0;
						while (advanceContextString.indexOf("well:", index) > 0) {

							// well:A1
							// targetName:target
							// baseLineName:AUTO
							// baselineStart:AUTO
							// baselineEnd:AUTO
							// useCTSetingBoo:true
							// autoBaselineBoolean:true
							String well = advanceContextString.substring(
									advanceContextString
											.indexOf("well:", index) + 5,
									advanceContextString.indexOf(
											",targetName:", index));
							String targetName = advanceContextString.substring(
									advanceContextString.indexOf("targetName:",
											index) + 11, advanceContextString
											.indexOf(",baseLineName:", index));
							String baseLineName = advanceContextString
									.substring(advanceContextString.indexOf(
											"baseLineName:", index) + 13,
											advanceContextString.indexOf(
													",baselineStart:", index));
							String baselineStart = advanceContextString
									.substring(advanceContextString.indexOf(
											"baselineStart:", index) + 14,
											advanceContextString.indexOf(
													",baselineEnd:", index));
							String baselineEnd = advanceContextString
									.substring(advanceContextString.indexOf(
											"baselineEnd:", index) + 12,
											advanceContextString.indexOf(
													",useCTSetingBoo:", index));
							Boolean useCTSetingBoo = Boolean.parseBoolean(advanceContextString
									.substring(advanceContextString.indexOf(
											"useCTSetingBoo:", index) + 15,
											advanceContextString.indexOf(
													",autoBaselineBoolean:",
													index)));

							int nextIndex = advanceContextString.indexOf(
									"autoBaselineBoolean:", index) + 20;
							if (advanceContextString.indexOf(",well:",
									nextIndex) < 0) {
								Boolean autoBaselineBoolean = Boolean.parseBoolean(advanceContextString.substring(
										advanceContextString.indexOf(
												"autoBaselineBoolean:", index) + 20,
										advanceContextString.length() - 1));

								for (AdvancedSettingBean bean : advancedSettingBeans) {
									if (bean.getWell().equals(well)) {
										bean.setTargetName(targetName);
										bean.setBaseLine(baseLineName);
										bean.setBaselineStart(baselineStart);
										bean.setBaselineEndString(baselineEnd);
										bean.setUseCTSetingBoo(useCTSetingBoo);
										bean.setAutoBaselineBoolean(autoBaselineBoolean);

									}
								}

							} else {
								Boolean autoBaselineBoolean = Boolean.parseBoolean(advanceContextString
										.substring(advanceContextString
												.indexOf(
														"autoBaselineBoolean:",
														index) + 20,
												advanceContextString.indexOf(
														",well:", nextIndex)));

								for (AdvancedSettingBean bean : advancedSettingBeans) {
									if (bean.getWell().equals(well)) {
										bean.setTargetName(targetName);
										bean.setBaseLine(baseLineName);
										bean.setBaselineStart(baselineStart);
										bean.setBaselineEndString(baselineEnd);
										bean.setUseCTSetingBoo(useCTSetingBoo);
										bean.setAutoBaselineBoolean(autoBaselineBoolean);

									}
								}

							}

							index = advanceContextString.indexOf(
									"autoBaselineBoolean:", index) + 21;

						}

					}
				}

				contextString.append("\r\n" + "\r\n" + "advancedSettingBeans"
						+ "\r\n");
				for (int i = 0; i < advancedSettingBeans.size(); i++) {
					contextString.append("\r\n" + "well" + ":"
							+ advancedSettingBeans.get(i).getWell());
					contextString.append("\r\n" + "targetName" + ":"
							+ advancedSettingBeans.get(i).getTargetName());
					contextString.append("\r\n" + "baseLineName" + ":"
							+ advancedSettingBeans.get(i).getBaseLine());
					contextString.append("\r\n" + "baselineStart" + ":"
							+ advancedSettingBeans.get(i).getBaselineStart());
					contextString.append("\r\n"
							+ "baselineEnd"
							+ ":"
							+ advancedSettingBeans.get(i)
									.getBaselineEndString());
					contextString.append("\r\n" + "useCTSetingBoo" + ":"
							+ advancedSettingBeans.get(i).getUseCTSetingBoo());
					contextString.append("\r\n"
							+ "autoBaselineBoolean"
							+ ":"
							+ advancedSettingBeans.get(i)
									.getAutoBaselineBoolean());
				}

				fileManagerUtil.createFIle(folderName, fileName);
				fileManagerUtil.writeFile(folderName, fileName, ""
						+ contextString, false);

				// fileManagerUtil.writeFile(folderName, fileName, "" + content,
				// true);

				 ByAlert.alert(getString(R.string.parameter_save));

			}
		});
	}

	private Handler messageListener = new Handler() {
		public void handleMessage(Message msg) {
			switch (msg.arg1) {
			case TASK_LOOP_COMPLETE:
				pd.dismiss();
				break;

			}
		}
	};

	@Override
	public void SendMessageValue(ArrayList<CtSettingBean> ctSettingBeans,
			Boolean defaultBaselineBoo, String defaultStart, String defaultEnd,
			Boolean defaultThresholdBoo, String defaultThreshold) {
		this.ctSettingBeans = ctSettingBeans;
		this.defaultBaselineBoo = defaultBaselineBoo;
		this.defaultStart = defaultStart;
		this.defaultEnd = defaultEnd;
		this.defaultThresholdBoo = defaultThresholdBoo;
		this.defaultThreshold = defaultThreshold;
		// ByAlert.alert("接口回调！");

	}

	@Override
	public void SendMessageValue(
			ArrayList<AdvancedSettingBean> advancedSettingBeans) {
		this.advancedSettingBeans = advancedSettingBeans;

	}

}
